package main

import (
	"fmt"
	"math/rand"
	"time"
)

func ninenineMultiplicationTable() {
	var n int
	for i := 1; i < 10; i++ {
		for j := 1; j <= i; j++ {
			if j == 1 {
				n = 2
			} else {
				n = 3
			}
			fmt.Printf("%d*%d=%-[3]*d", j, i, n, i*j)
		}
		fmt.Println()
	}
}

func random() {
	r := rand.New(rand.NewSource(time.Now().UnixNano()))
	var sum = 0
	var multiply uint64 = 1 // 极小情况下，可能超过int上界，使用uint64合适
	for i := 0; i < 20; i++ {
		v := r.Intn(99) + 1
		fmt.Println(v)
		if i%2 == 0 {
			sum += v
		} else {
			multiply = multiply * uint64(v)
		}
	}
	fmt.Println(sum, multiply)
}

// 100以内斐波那契数列
func feb(limit int) {
	a, b := 1, 1
	limit = 100
	for {
		b, a = a+b, b
		if b >= limit {
			break
		}
		fmt.Println(b)
	}
}

func main() {
	ninenineMultiplicationTable()
	fmt.Println("---------------")
	random()
	fmt.Println("---------------")
	feb(100)
}
